import React, { Component } from "react";
import PubSub from "pubsub-js";
import { Route, NavLink, Switch } from "react-router-dom";
import Params from "./params";
export default class A extends Component {
  state = {
    id: 1,
  };

  handlePub = () => {
    PubSub.publish("pubsub", { name: "张三", age: 18 });
  };
  render() {
    return (
      <div>
        <h4>Params传参</h4>
        <hr />
        <NavLink to={`/home/a/params/${this.state.id}`}>Params</NavLink>
        <hr />
        <Switch>
          <Route path="/home/a/params/:id" component={Params}></Route>
        </Switch>
        <button onClick={this.handlePub}>发布消息</button>
      </div>
    );
  }
}
